<!DOCTYPE html>
<html>
<head lang="zh-cmn-Hans">
    <meta charset="UTF-8">
    <title>Fly.js Demo</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=0.5,user-scalable=no"/>
    <!--[if lt IE 9]>
    <script src="//cdn.bootcss.com/es5-shim/4.5.9/es5-shim.min.js"></script>
    <script src="//cdn.bootcss.com/es5-shim/4.5.9/es5-sham.min.js"></script>
    <script src="//cdn.bootcss.com/json3/3.3.2/json3.min.js"></script>
    <![endif]-->
    <!--[if lt IE 10]>
    <script src="//cdn.bootcss.com/jquery-placeholder/2.3.1/jquery.placeholder.min.js"></script>
    <![endif]-->
    <!--<script src="https://cdn.bootcss.com/axios/0.16.2/axios.js"></script>-->
    <script src="../dist/fly.min.js"></script>

</head>
<style>
    html {
        font-size: 20px;
        -webkit-user-select: none;
    }
</style>
<body>
<div style="background: teal; font-size: 38px; color: #ffef68; text-shadow: 2px 2px 5px #ffef68; width: 400px; height: 400px; text-align: center">
   <div style="padding-top: 100px"> Fly.js</div>
</div>
open console panel to view log.
<script>
    //定义公共headers
    fly.config.headers={xx:5,bb:6,dd:7}

    fly.interceptors.request.use(function(config,promise){
        //可以通过promise.reject／resolve直接中止请求
        console.log("interceptors.request", config)
        config.headers["X-Tag"]="fly.js";
        return config;
    })

    fly.interceptors.response.use(
        function(response,promise){
            console.log("interceptors.response", response)
            return response.data
        },
        function(err,promise){
            //promise.resolve("ssss")
        }
    )

    fly.get("../package.json",{aa:8,bb:9,tt:{xx:5}})
        .then(function(d){
        console.log("get result:",d)
    }).catch(function(e){
        console.log("error", e)
    })

    fly.post("../package.json",{aa:8,bb:9,tt:{xx:5}})
        .then(function(d){
        console.log("post result:",d)
    }).catch(function(e) {
        console.log("error", e)
    })

    fly.request("../package.json",{hh:5},{method:"post"})
        .then(function(d){
        console.log("ajax result:",d)
    })

</script>
</body>
</html>